package hu.myandroidlife;

import java.text.SimpleDateFormat;
import java.util.Date;

import hu.myandroidlife.base.BaseActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

public class TempActivity extends BaseActivity {

	private TextView tvCardName;
	private TextView tvDate;
	private TextView tvMusicItem;
	private TextView tvCureItem;
	private TextView tvSleepItem_1;
	private TextView tvSleepItem_2;
	private TextView tvSleepItem_3;
	private TextView tvSleepItem_4;
	
	private Intent mIntent;

	@Override
	protected int getLayoutId() {
		return R.layout.activity_temp;
	}

	@Override
	protected void initView() {
		tvCardName=$findViewById(R.id.tvCardName);
		tvDate=$findViewById(R.id.tvDate);
		tvMusicItem=$findViewById(R.id.tvMusicItem);
		tvCureItem=$findViewById(R.id.tvCureItem);
		tvSleepItem_1=$findViewById(R.id.tvSleepItem_1);
		tvSleepItem_2=$findViewById(R.id.tvSleepItem_2);
		tvSleepItem_3=$findViewById(R.id.tvSleepItem_3);
		tvSleepItem_4=$findViewById(R.id.tvSleepItem_4);
		
		mIntent=getIntent();
		Bundle _Bundle=mIntent.getExtras();
		String _Value=_Bundle.getString("recipe");
		$showMsg(_Value);
		String[] _Array=dealRecipeStr(_Value,",");
		if(_Array!=null){
			String[] _ArrayItem1=dealRecipeStr(_Array[0], "_");
			tvCardName.setText(_ArrayItem1[0]);
			tvDate.setText(getFormatedDateTime("yyyy-MM-dd hh:mm:ss",Long.parseLong(_ArrayItem1[1])));
			tvMusicItem.setText(_Array[1]);
			tvCureItem.setText(_Array[2]);
			tvSleepItem_1.setText(_Array[3]);
			tvSleepItem_2.setText(_Array[4]);
			tvSleepItem_3.setText(_Array[5]);
			tvSleepItem_4.setText(_Array[6]);
		}
		
	}

	@Override
	protected void initListener() {
		
	}

	@Override
	protected void widgetClick(View v) {
		
	}
	
	/**
	 * 对字符串进行处理
	 */
	private String[] dealRecipeStr(String pRecipe,String pSplitStr){
		if(pRecipe==null){
			return null;
		}
		String[] _Array=pRecipe.split(pSplitStr);
		
		return _Array;
	}
	
	
	
	/**
	 * 将时间（毫秒）格式化成 yyyy-MM-dd hh:mm:ss
	 */
	private  String getFormatedDateTime(String pattern, long dateTime) {
        SimpleDateFormat sDateFormat = new SimpleDateFormat(pattern);
        return sDateFormat.format(new Date(dateTime ));
    }
}
